package com.cunshe.web.manage;

import com.cunshe.common.ResponseVO;
import com.cunshe.config.annotation.Login;
import com.cunshe.dao.MemorabiliaDao;
import com.cunshe.domain.Memorabilia;
import com.cunshe.service.MemorabiliaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 大事记
 */
@Api(tags = "大事记")
@Login
@RestController
@RequestMapping(value = "/manage/memorabilia")
public class MemorabiliaController {

    @Autowired
    private MemorabiliaService memorabiliaService;

    @ApiOperation(value = "新增")
    @PostMapping(value = "insert")
    public ResponseVO insert(@RequestBody Memorabilia record) {
        memorabiliaService.insert(record);
        return ResponseVO.success();
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "delete")
    public ResponseVO delete(@RequestParam("id") Long id) {
        memorabiliaService.delete(id);
        return ResponseVO.success();
    }

    @ApiOperation(value = "修改")
    @PostMapping(value = "update")
    public ResponseVO update(@RequestBody Memorabilia record) {
        memorabiliaService.update(record);
        return ResponseVO.success();
    }

    @ApiOperation(value = "查询")
    @PostMapping(value = "list")
    public ResponseVO<List<Memorabilia>> list() {
        List<Memorabilia> list = memorabiliaService.list();
        return ResponseVO.success(list);
    }

}